Average Case and Distributional Analysis of Java 7's Dual Pivot Quicksort
نویسندگان
چکیده
In 2009, Oracle replaced the long-serving sorting algorithm in its Java 7 runtime library by a new dual pivot Quicksort variant due to Yaroslavskiy. The decision was based on the strikingly good performance of Yaroslavskiy’s implementation in running time experiments. At that time, no precise investigations of the algorithm were available to explain its superior performance — on the contrary: Previous theoretical studies of other dual pivot Quicksort variants even discouraged the use two pivots. Only in 2012, two of the authors gave an average case analysis of a simplified version of Yaroslavskiy’s algorithm, proving that savings in the number of comparisons are possible. However, Yaroslavskiy’s algorithm needs more swaps, which renders the analysis inconclusive. To force the issue, we herein extend our analysis to the fully detailed style of Knuth: We determine the exact number of executed Java Bytecode instructions. Surprisingly, Yaroslavskiy’s algorithm needs sightly more Bytecode instructions than a simple implementation of classic Quicksort — despite contradicting running times. Like in Oracle’s library implementation we incorporate the use of Insertionsort on small subarrays and show that it indeed speeds up Yaroslavskiy’s Quicksort in terms of Bytecodes. Even if using optimal Insertionsort thresholds the new Quicksort variant again needs slightly more Bytecode instructions on average. Finally, we show that the (suitably normalized) costs of Yaroslavskiy’s algorithm converge to a random variable whose distribution is characterized by a fix point equation. From that, we compute variances of costs and show that for large n, costs are concentrated about their mean.
منابع مشابه
Pivot Sampling in Java 7's Dual-Pivot Quicksort
The new dual-pivot Quicksort by Vladimir Yaroslavskiy — used in Oracle’s Java runtime library since version 7 — features intriguing asymmetries in its behavior. They were shown to cause a basic variant of this algorithm to use less comparisons than classic single-pivot Quicksort implementations. In this paper, we extend the analysis to the case where the two pivots are chosen as fixed order sta...
متن کاملAverage Case Analysis of Java 7's Dual Pivot Quicksort
Recently, a new Quicksort variant due to Yaroslavskiy was chosen as standard sorting method for Oracle’s Java 7 runtime library. The decision for the change was based on empirical studies showing that on average, the new algorithm is faster than the formerly used classic Quicksort. Surprisingly, the improvement was achieved by using a dual pivot approach, an idea that was considered not promisi...
متن کاملPivot Sampling in Dual-Pivot Quicksort
The new dual-pivot Quicksort by Vladimir Yaroslavskiy — used in Oracle’s Java runtime library since version 7 — features intriguing asymmetries in its behavior. They were shown to cause a basic variant of this algorithm to use less comparisons than classic single-pivot Quicksort implementations. In this paper, we extend the analysis to the case where the two pivots are chosen as fixed order sta...
متن کاملEngineering Java 7's Dual Pivot Quicksort Using MaLiJan
Recent results on Java 7’s dual pivot Quicksort have revealedits highly asymmetric nature. These insights suggest that asymmetric pivot choices are preferable to symmetric onesfor this Quicksort variant. From a theoretical point of view,this should allow us to improve on the current implementa-tion in Oracle’s Java 7 runtime library. In this paper, weuse our new tool MaLiJAn...
متن کاملWhy Is Dual-Pivot Quicksort Fast?
I discuss the new dual-pivot Quicksort that is nowadays used to sort arrays of primitive types in Java. I sketch theoretical analyses of this algorithm that offer a possible, and in my opinion plausible, explanation why (a) dual-pivot Quicksort is faster than the previously used (classic) Quicksort and (b) why this improvement was not already found much earlier.
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید
ثبت ناماگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید
ورودعنوان ژورنال:
- CoRR
دوره abs/1304.0988 شماره
صفحات -
تاریخ انتشار 2013